package com.zzq.base.awesome.utils;

import com.zzq.base.awesome.entity.CommonData;
import com.zzq.base.awesome.controller.IgnoreUrlList;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 赵自强
 * */
public class StringTypeUtil {
	private static Pattern phonePattern = Pattern.compile(CommonData.MOBILREGX);
	private static Pattern emailPattern = Pattern.compile(CommonData.EMAILREGX);
	/**
	 * 描述：是否是邮箱.
	 * @param str 指定的字符串
	 * @return 是否是邮箱:是为true，否则false
	 */
	public static Boolean isEmail(String str) {
		Matcher matcher = emailPattern.matcher(str);

		if (matcher.matches()) {
			return true;
		}
		return false;
	}

	/**
	 * 判断是否是手机号
	 *
	 * @param phone
	 * @return
	 */
	public static boolean checkPhone(String phone) {

		Matcher matcher = phonePattern.matcher(phone);

		if (matcher.matches()) {
			return true;
		}
		return false;
	}

	public static boolean isIgnoreUrl(String url) {
		if (IgnoreUrlList.setContains(url)) {
			return true;
		}
		if (IgnoreUrlList.listHaveStarter(url)) {
			return true;
		}
		return false;
	}
}
